﻿@{	
	Page.Title = "Product";

	var db = Database.Open("bakery");
    
    var option = UrlData[0];
}

<h2>Which sample would you like to see?</h2>
<ul>
    <li><a href="@Href("~/Products/SimplePay")">Simple Payment</a></li>
    <li><a href="@Href("~/Products/ChainedPay")">Chained Payment</a></li>
</ul>


@if (option != "ChainedPay")
{
    <h2>PayPal Simple Payment</h2>
    <p>
        This is an example of Simple Pay.  It's the quickest and easiest way to get started
        accepting payments on your website.
    </p>
    <div class="products group">
        @foreach (var p in db.Query("SELECT * FROM PRODUCTS")) {
            <div class="product">
                <h3>@p.Name</h3>
                <img src="@Href("~/Images/"+ p.ImageName)" alt="@p.Name"/>
                <p>@p.Description</p>
                <ul class="group">
                    <li class="price">$@string.Format("{0:f}", p.Price)</li>
                    <li class="order">
                        <form id="frmSimple" action="@Href("~/OrderSimple")" method="post">
                            <input type="hidden" name="ProductId" value="@p.Id"/>
                            <input type="submit" value="Order Now"/>
                        </form>
                    </li>
                <ul>
            </div>
        }    
    </div>
}
else 
{
    <h2>PayPal Chained Payment</h2>
    <p>
        This is an example of Chained Payment.  Chained Payment lets you accept payment 
        from a customer just like in Simple Pay but it lets you send the funds to multiple 
        PayPal accounts.  This is great for if you have suppliers to pay and you want to 
        automatically pay them as soon as you make a sale.
    </p>
    <div class="products group">
        @foreach (var p in db.Query("SELECT * FROM PRODUCTS")) {
            <div class="product">
                <h3>@p.Name</h3>
                <img src="@Href("~/Images/"+ p.ImageName)" alt="@p.Name"/>
                <p>@p.Description</p>
                <ul class="group">
                    <li class="price">$@string.Format("{0:f}", p.Price)</li>
                    <li class="order">
                        <form id="frmChained" action="@Href("~/OrderChained")" method="post">
                            <input type="hidden" name="ProductId" value="@p.Id"/>
                            <input type="submit" value="Order Now"/>
                        </form>
                    </li>
                <ul>
            </div>
        }    
    </div>
}


